<template>
	<view>
		<!-- 	<view-navbar></view-navbar> -->
		<view class="margin">
			<view class="ml32 h100 mt12 ms20"><u-search placeholder="手机号" @search="search" v-model="keyword" :showAction="false"
					actionText="取消"></u-search></view>
			<view class="tabs ms15">
				<u-tabs :list="changeList" @click="click" :current="current" lineWidth="126rpx" lineColor="#7976E9" :activeStyle="{
					color: '#7976E9',
					fontWeight: 'bold',
					transform: 'scale(1.05)'
				}" :inactiveStyle="{
	color: '#848484',
	transform: 'scale(1)',
	fontWeight: 'bold',
}" itemStyle="padding-left: 140rpx; padding-right: 140rpx; height: 68rpx;"></u-tabs>
			</view>
			<!-- sq -->
			<view class="" v-if="current == 0">
				<block v-for="(v, i) in list0" :key="i">
					<view class="item h-50 ms10 ">
						<u-row>
							<u-col span="2">
								<image class="circle mr10" :src="v.avatar" style="width: 60rpx;height: 60rpx;" mode="heightFix"></image>
							</u-col>
							<u-col span="2">
								<view class="text-bold size_16">
									{{ v.unickname }}
								</view>
							</u-col>
							<u-col span="5">

							</u-col>
							<u-col span="3">
								<!-- color="#AE51FF" -->
								<u-button v-if="v.fstatus == 0" shape='circle' plain type="info" text="待验证"></u-button>
								<u-button v-if="v.fstatus == 1" shape='circle' plain  type="primary" text="已同意"></u-button>
								<u-button v-if="v.fstatus == 2" shape='circle' plain type="warning" text="被拒绝"></u-button>
							</u-col>
							<!-- <u-col span="5"> -->
							<!-- </u-col> -->
							<!-- <u-col span="3"> -->
							<!-- <u-button style="display: none;" type="info" text=""></u-button> -->
							<!-- <u-button shape='circle' size="large" text="关注" color="#AE51FF"></u-button> -->
							<!-- </u-col> -->
						</u-row>
					</view>
				</block>
			</view>
			<!-- sqed -->
			<view class="" v-if="current == 1">
				<block v-for="v, i in list1" :key="i">
					<view class="item h-50 ms10 ">
						<u-row>
							<u-col span="2">
								<image class="circle mr10" :src="v.avatar" style="width: 60rpx;height: 60rpx;" mode="heightFix"></image>
							</u-col>
							<u-col span="2">
								<view class="text-bold size_16">
									{{ v.unickname }}
								</view>
							</u-col>
							<u-col span="5">

							</u-col>
							<u-col span="3">
								<!-- color="#AE51FF" -->
								<u-button v-if="v.fstatus == 0" shape='circle' plain @click="agreeFriend(v, 1)" type="info"
									text="同意"></u-button>
								<u-button v-if="v.fstatus == 0" shape='circle' plain @click="agreeFriend(v, 2)" type="warning"
									text="拒绝"></u-button>
								<u-button v-if="v.fstatus == 1" shape='circle' plain  type="primary" text="已同意"></u-button>
								<u-button v-if="v.fstatus == 2" shape='circle' plain type="info" text="已拒绝"></u-button>
							</u-col>
						</u-row>
					</view>
				</block>
			</view>
		</view>
	</view>
</template>

<script>
export default {
	data() {
		return {
			/* 搜索 */
			keyword: '',
			searchForm: {
				pageNum: 10,
				pageSize: 1,
				type: 0
			},
			current: 0,
			changeList: [{
				name: '好友申请',
				index: 0
			}, {
				name: '被申请',
				index: 1
			},],

			/* sq */
			list0: [],
			/* sqed */
			list1: [],
			/* 结果 */
			friendList: []
		};
	},
	mounted() {
		this.getFriendListApply0();
	},
	methods: {
		click(e) {
			this.current = e.index
			if (this.current == 1) {
				this.getFriendListApply1()
			} else {
				this.getFriendListApply0()
			}
		},
		async search(e) {
			let re = await this.$API.friendApi.findFriendByPhone(e);
			uni.navigateTo({
				url: `/pages/searchFriend/searchFriend?data=` + encodeURIComponent(JSON.stringify(re))
			});
		},
		async agreeFriend(e, status) {
			console.log(e, status, "e,status");
			let re = await this.$API.friendApi.agreeFriend({
				friendId: e.friendId,
				fstatus: status,
			});

			console.log(re, "re");
		},
		async getFriendListApply0(e) {
			console.log(this.searchForm, "this.searchForm");
			this.searchForm.type = 0
			let re = await this.$API.friendApi.applyOrapplyed(this.searchForm);
			this.list0 = re
		},

		async getFriendListApply1(e) {
			this.searchForm.type = 1
			let re = await this.$API.friendApi.applyOrapplyed(this.searchForm);
			this.list1 = re
		}
	}
};
</script>

<style lang="scss" scoped>
/* #ifdef MP */
::v-deep .u-search__content__input {
	font-size: 28rpx !important;
}

/* #endif */
.word {
	border-radius: 0rpx 0rpx 0rpx 0rpx;
	opacity: 1;
	margin: 12rpx 702rpx 10rpx 32rpx;
}

.menList {
	// width: 686rpx;
	// height: 108rpx;
	opacity: 1;

	.right {
		width: 590rpx;
		height: 108rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		opacity: 1;
	}
}
</style>